home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / help / fvscope < prev    next >
Text File  |  1994-04-25  |  2KB  |  54 lines

  1. fvscope:
  2.  
  3. Syntax:    fvscope ( FNAME )
  4.     fvscope ( FNAME , FILE )
  5. Description:
  6.  
  7.     The fvscope function examines the compiled form of the
  8.     user-function, identified by FNAME, and prints a listing of
  9.     all the variables used within the function. Additionally the
  10.     scope of each variable is printed.
  11.  
  12.     The second, and optional argument, is a string that denoted a
  13.     filename, or output process for fvscope to write it's output
  14.     to. 
  15.  
  16.     Fvscope is useful for writing general purpose functions that
  17.     will be used by others. It can be used to identify errant
  18.     global variables (variables that should be local, but were
  19.     overlooked). 
  20.  
  21.     Example:
  22.  
  23.     > x = function ( y )
  24.       {
  25.         local (z)
  26.       
  27.         z = 2*y + zz;
  28.         return z
  29.       }
  30.         <user-function>
  31.     > fvscope (x);
  32.         Function Variable SCOPE analysis for : x
  33.         Filename: stdin
  34.     
  35.         line    GLOBAL            ARG        LOCAL
  36.     
  37.            1                        Local-Var: z
  38.            1                Arg-Var: y
  39.            1    Global-Var: zz
  40.            1                        Local-Var: z
  41.  
  42.     The above example shows a trivial user-function, and the
  43.     output from fvscope. Notice the typo on the 5th line of the
  44.     function (`z = 2*y + zz;'), which should have read: `z = 2*y +
  45.     z;'. Fvscope identifies the variable `zz' as a global
  46.     variable, signaling the function author (who did not want to
  47.     use any global variables) that there is an error.
  48.  
  49.     Also note that the line numbers in the above example are all
  50.     1. In this particular case (the function is entered at the
  51.     command line) this behavior is correct. When running fvscope()
  52.     on a function that is stored in a file, the proper line
  53.     numbers will be reported.
  54.